package com.qh.yyxt.pojo;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.qh.yyxt.entity.BorrowThing;
import com.qh.yyxt.pojo.entity.thing.Thing;
import com.qh.yyxt.pojo.entity.thing.ThingSize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class TableDTO
{
    //对应的borrow_thing的id
    @JsonProperty("id")
    private Integer id;
    @JsonProperty("fId")
    private Integer fId;
    @JsonProperty("sId")
    private Integer sId;
    //物品名称
    @JsonProperty("name")
    private String name;
    //单位
    @JsonProperty("unite")
    private String unite;
    @JsonProperty("size")
    private String size;
    //借走的总数量
    @JsonProperty("num")
    private Integer num;
    //归还的数量
    @JsonProperty("acNum")
    private Integer acNum;
    //损坏的数量
    @JsonProperty("badNum")
    private Integer badNum;
    @JsonProperty("state")
    private String state;
    public void setTableDTO(Thing thing, ThingSize thingSize, BorrowThing borrowThing)
    {
        if(thing!=null)
        {
            this.name=thing.getName();
            this.unite=thing.getUnit();
        }
        if(thingSize!=null)
        {
            size=thingSize.getSize();
        }
        if(borrowThing!=null)
        {
            this.id=borrowThing.getId();
            this.fId=borrowThing.getFid();
            this.sId=borrowThing.getSid();
            this.num=borrowThing.getNum();
            this.acNum=borrowThing.getAcnum();
            this.badNum=borrowThing.getBadnum();
            this.state=borrowThing.getState();
        }
    }
    public String getInfo(){
        return name+"--"+size+"："+num+unite;
    }
}
